package spring.my.db.sharding.demo.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.time.LocalDateTime;
import java.util.HashMap;

@Controller
public class TestController {
    private static final Logger log = LoggerFactory.getLogger(TestController.class);

    @RequestMapping(value = "/index", method = RequestMethod.POST)
    public String index(HashMap<String, Object> map) {
        map.put("name", "小明");
        System.out.println("请求成功....");
        return "/pages/index";
    }

    @RequestMapping(value = "/log", method = RequestMethod.GET)
    @ResponseBody
    public String log() {
        log.info(">>>> 时间: " + LocalDateTime.now());
        System.out.println("请求成功....");
        return "/pages/index";
    }

    public static void main(String[] args) {
        log.info("info");
        log.debug("debug");
        log.warn("warn");
        log.error("error");
        System.out.println(">>> over");
    }

}
